﻿namespace FlyingEye
{
    /// <summary>
    /// 默认 HTTP 操作返回结果
    /// </summary>
    public class DefaultResult
    {
        public string? Message { get; set; }

        public bool IsSuccess { get; set; }

        public static DefaultResult GetFailureResult(string? message = null)
        {
            return new DefaultResult()
            {
                Message = message,
                IsSuccess = false
            };
        }

        public static DefaultResult GetSuccessResult(string? message = null)
        {
            return new DefaultResult()
            {
                Message = message,
                IsSuccess = true
            };
        }
    }

    /// <summary>
    /// 默认 HTTP 操作返回结果
    /// </summary>
    /// <typeparam name="TResult"></typeparam>
    public class DefaultResult<TResult> : DefaultResult
    {
        public TResult? Result { get; set; }

        public static DefaultResult<TResult> GetSuccessResult(TResult? result = default, string? message = "")
        {
            return new DefaultResult<TResult>()
            {
                IsSuccess = true,
                Message = message,
                Result = result
            };
        }

        public static DefaultResult<TResult> GetFailureResult(string? message = null, TResult? result = default)
        {
            return new DefaultResult<TResult>()
            {
                IsSuccess = false,
                Message = message,
                Result = result
            };
        }
    }
}
